home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Circle_pattern.ieb 1.1, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 24/1 1997 Stockholm/Sweden ** ** Place PRIMARY images in a circular pattern on SECONDARY image. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ /* F = Current image number */ get_info: back = 'OK S2 F' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Xoff=128 ; Yoff=128 ; Angle=0 ; Radius=64 if command ~= '' then parse var command Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate 'IE_TO_FRONT' form = 'FORM "Circle Pattern" " OK | Cancel "', ' INTEGER,"X offset",0,4096,'Xoff',SLIDER', ' INTEGER,"Y offset",0,4096,'Yoff',SLIDER', ' INTEGER,"Rotation angle",-3600,3600,'Angle',SLIDER', ' INTEGER,"Pattern radius",0,4096,'Radius',SLIDER' if command = '' then do form = form||' CYCLE,"Composite method","Add|Difference|Max|Min|Multiply|Subtract",0', ' INTEGER,"Number of objects",1,360,5,SLIDER', ' CHECKBOX,"Rotate objects within circle?",1' form parse var result ok Xoff Yoff Angle Radius CFunk Objects Rotate if ok = 0 then return '<ERROR>' select when CFunk = 0 then CFunk = 'ADD' when CFunk = 1 then CFunk = 'DIFFERENCE' when CFunk = 2 then CFunk = 'MAX' when CFunk = 3 then CFunk = 'MIN' when CFunk = 4 then CFunk = 'MULTIPLY' when CFunk = 5 then CFunk = 'SUBTRACT' end end else do form parse var result ok Xoff Yoff Angle Radius if ok = 0 then return '<ERROR>' CFunk = 'none' Objects = 'none' Rotate = 'none' end back = Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' '"'sec_image'"' '"'frame':'num_frames'"' parse var options Xoff Yoff '#'Cfunk '#'Objects Angle Radius '#'Rotate if add_mathlib() = '<ERROR>' then return '<ERROR>' 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result 'OPEN' '"'sec_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load SECONDARY image:' d2c(10)||sec_image'"' '" OK "' return '<ERROR>' end else SecImage = result do until ((Angle < 360)&(Angle >= 0)) if Angle > 359 then Angle = Angle - 360 if Angle < 0 then Angle = Angle + 360 end 'PROJECT_INFO' LoadImage 'WIDTH' /* PRI image width */ PIW = RESULT 'PROJECT_INFO' LoadImage 'HEIGHT' /* PRI image height */ PIH = RESULT 'PROJECT_INFO' SecImage 'WIDTH' /* SEC image width */ SIW = RESULT 'PROJECT_INFO' SecImage 'HEIGHT' /* SEC image height */ SIH = RESULT do i = 1 to Objects ObjAngle = Angle+((i-1)*360/Objects) NewXoff = Xoff + trunc( cos(((ObjAngle)/360*6.2831853)+1.57079633)*Radius ) NewYoff = Yoff + trunc( sin(((ObjAngle)/360*6.2831853)+1.57079633)*Radius ) ObjAngle = trunc( ObjAngle ) if (Rotate = 1)&(ObjAngle ~= 0) then do 'ROTATE' LoadImage ObjAngle CalcType /* Rotate image */ NewLoadImage = result end /* do rotate within */ else NewLoadImage = LoadImage 'PROJECT_INFO' NewLoadImage 'WIDTH' /* NewPRI image width */ NewPIW = Result 'PROJECT_INFO' NewLoadImage 'HEIGHT' /* NewPRI image height */ NewPIH = Result NewXoff = NewXoff - trunc( NewPIW/2 ) NewYoff = NewYoff - trunc( NewPIH/2 ) if NewXoff < -NewPIW then NewXoff = -NewPIW if NewXoff > SIW then NewXoff = SIW if NewYoff < -NewPIH then NewYoff = -NewPIH if NewYoff > SIH then NewYoff = SIH 'MARK' NewLoadImage 'PRIMARY' 'MARK' SecImage 'SECONDARY' 'COMPOSITE' NewXoff NewYoff CFunk NewSecImage = Result 'CLOSE' SecImage SecImage = NewSecImage if (Rotate = 1)&(ObjAngle ~= 0) then 'CLOSE' NewLoadImage end /* Objects loop */ 'CLOSE' LoadImage OutputImage = SecImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ add_mathlib: if ~show(L,'rexxmathlib.library') then do if exists('LIBS:rexxmathlib.library') then do if ~addlib('rexxmathlib.library',0,-30,0) then do 'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib found on disk */ else do 'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "' return '<ERROR>' end end /* lib exists in mem */ return 'OK' /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'